feat(cli): add --app_name to decouple session/artifact storage from folder#6467
Open
amitjborate wants to merge 4 commits into
Open
feat(cli): add --app_name to decouple session/artifact storage from folder#6467amitjborate wants to merge 4 commits into
amitjborate wants to merge 4 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
amitjborate
force-pushed
the
feat/app-name-override
branch
from
July 24, 2026 21:22
b37dd2a to
e8025fa
Compare
…older name When agents are served via `adk web` / `adk api_server` by passing a directory, the app_name used to key sessions and artifacts is derived from the agent's folder name. Two servers that load an identically-named agent folder against a shared session/artifact backend therefore write to the same app_name and unintentionally share each other's sessions. There was no supported way to override the app_name on the directory-launch path. This adds an optional app_name override: - `get_fast_api_app(app_name=...)` - `--app_name` CLI flag on `adk web` and `adk api_server` - `ADK_APP_NAME` environment variable (fallback) When set, the session and artifact services are wrapped so their `app_name` is pinned to the override, while the agent loader, REST routes and web UI keep using the folder name. Servers loading the same folder can thus be given distinct app_names to isolate their persisted data (or the same app_name to share it, on purpose) without renaming the folder. The change is opt-in: when no override is supplied the services are returned unchanged, so existing deployments on any backend are unaffected. The wrapper operates at the BaseSessionService/BaseArtifactService abstraction (it only rewrites the app_name string), so it is storage-agnostic. Tests cover the wrapper logic, the get_fast_api_app wiring, and a backend matrix (in-memory, DatabaseSessionService via sqlite+aiosqlite -- the same class Postgres/MySQL use -- and SqliteSessionService).
amitjborate
force-pushed
the
feat/app-name-override
branch
from
July 24, 2026 21:30
723bae8 to
b61e6e8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When agents are served via
adk web/adk api_serverby passing a directory, theapp_nameused to key sessions and artifacts is derived from the agent's folder name. Two servers that load an identically-named agent folder against a shared session/artifact backend therefore write under the sameapp_nameand unintentionally share each other's sessions. There is currently no supported way to override theapp_nameon the directory-launch path (ADK_DEFAULT_APP_NAMEonly injects a default when a client omits it; it does not decouple storage from the folder name).This PR adds an optional
app_nameoverride, exposed three ways:get_fast_api_app(app_name=...)--app_nameCLI flag onadk webandadk api_serverADK_APP_NAMEenvironment variable (fallback)When set, the session and artifact services are wrapped so their
app_nameis pinned to the override, while the agent loader, REST routes, and web UI keep using the folder name. Servers loading the same folder can thus be given distinctapp_names to isolate their persisted data — or the same one to share it, on purpose — without renaming the folder.Motivation / use case
Running multiple instances of the same agent (e.g. one server per tenant/channel) against a shared session backend (Postgres, MySQL, …), launched by pointing at a directory whose folder name is identical across instances. Today their sessions collide. With this change each instance sets a distinct
--app_nameand stays isolated.Design
A thin decorator (
google/adk/cli/utils/app_name_override.py) wrapsBaseSessionService/BaseArtifactServiceand rewrites only theapp_namekeyword argument before delegating; every other argument and any implementation-specific attribute passes through unchanged. Because this operates at the abstraction layer, it is storage-agnostic — it never touches SQL, drivers, connection strings, or schema.The session/artifact routes and the
Runnerboth flow through the same wrapped service instance, so a single wrap covers the REST session CRUD, the web UI, and agent runs consistently.session.app_namealready carries the override on theappend_eventpath (the session was created/fetched through the wrapper), so no rewrite is needed there.Backward compatibility
Fully opt-in. When no override is supplied,
maybe_override_app_namereturns the services unchanged, so the new code path is never entered for existing deployments — behavior is byte-for-byte identical on every backend. The new function argument is keyword-only with aNonedefault, and the new CLI flag / env var default to unset.Scope / follow-ups
Covers the two app-scoped stores with a clean
app_name=interface: sessions and artifacts. The memory service is intentionally left for a follow-up — itsadd_session_to_memory(session)carriesapp_nameinside theSessionobject rather than as a kwarg, and ADK ships no SQL-backed memory service (memory is per-processmemory://or Vertexrag:///agentengine://), so it is unaffected by shared-SQL-database setups.Tests
tests/unittests/cli/utils/test_app_name_override.py(10 tests):maybe_override_app_nameis a no-op without an override and wraps when given one.test_override_is_backend_agnostic:InMemorySessionService,DatabaseSessionService(sqlite+aiosqlite— the same class Postgres/MySQL use), andSqliteSessionService. DB backends areimportorskip-guarded so the suite still runs where optional drivers are absent.All 10 pass locally.